﻿package manager
{
    import base.component.*;
    import com.sh.game.pool.*;
    import consts.*;
    import flash.utils.*;

    public class TimeOutManager extends Object
    {
        private var _timers:Object;
        private static var _instance:TimeOutManager;

        public function TimeOutManager()
        {
            this._timers = new Object();
            ObjectPoolManager.getInstance().initPool(Constant.UITimeOutConstant, 20);
            return;
        }// end function

        public function setTimer(param1:Function, param2:Number, ... args) : uint
        {
            args = ObjectPoolManager.getInstance().borrowItem(Constant.UITimeOutConstant) as TimerInfo;
            var _loc_5:* = setTimeout(args.doit, param2);
            args.init(_loc_5, param1, args);
            this._timers[args.id] = args;
            return args.id;
        }// end function

        public function clearTimer(param1:int) : void
        {
            var _loc_2:* = this._timers[param1];
            if (_loc_2 != null)
            {
                ObjectPoolManager.getInstance().returnItem(Constant.UITimeOutConstant, _loc_2);
                delete this._timers[param1];
            }
            return;
        }// end function

        public function clearAll() : void
        {
            var _loc_1:String = null;
            for (_loc_1 in this._timers)
            {
                
                this.clearTimer(int(_loc_1));
            }
            return;
        }// end function

        public static function getInstance() : TimeOutManager
        {
            if (!_instance)
            {
                _instance = new TimeOutManager;
            }
            return _instance;
        }// end function

    }
}
